package com.wgf.utils;

import org.springframework.ai.tool.annotation.Tool;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class ExpressTools
{

    @Tool(description = "用于查询我的快递信息")
    public List<Express> getExpress(String state)
    {
        // 快递数据
        List<Express> expressList = getData();
        // 根据状态进行快递查询
        return expressList.stream().filter(e -> e.state.equalsIgnoreCase(state)).collect(Collectors.toList());
    }

    /**
     * 获取全部快递数据
     *
     * @return
     */
    private List<Express> getData()
    {
        List<Express> list = new ArrayList<>();

        LocalDateTime now = LocalDateTime.now();

        list.add(new Express(1001L, "云南", "北京", now.plusDays(1), "未发货"));
        list.add(new Express(1002L, "广州", "西安", now.minusDays(2), "运送中"));
        list.add(new Express(1003L, "深圳", "湖南", now.minusDays(3), "运送中"));
        list.add(new Express(1004L, "北京", "西安", now.minusDays(10), "已签收"));

        return list;
    }


    /**
     * 快递对象
     *
     * @param id
     * @param from
     * @param to
     * @param createTime
     * @param state
     */
    record Express(Long id, String from, String to, LocalDateTime createTime, String state) { }


    /**
     * 测试LocalDateTime ，当前时间/加/减
     * @param args
     */
    public static void main(String[] args)
    {
        LocalDateTime now = LocalDateTime.now();

        System.out.println(now);
        System.out.println(now.plusDays(3));
        System.out.println(now.minusDays(3));
    }
}